package com.itkjb.leisurely.resource.sys.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itkjb.leisurely.resource.sys.model.SysStationRoleModel;
import com.itkjb.leisurely.resource.sys.mapper.SysStationRoleMapper;
import com.itkjb.leisurely.resource.sys.service.ISysStationRoleService;
import com.itkjb.leisurely.core.base.service.impl.BaseServiceImpl;

import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
/**
 * <p>
 * 岗位绑定角色 服务实现类
 * </p>
 *
 * @author itkjb.com
 * @since 2020-08-11
 */
@Service
public class SysStationRoleServiceImpl extends BaseServiceImpl<SysStationRoleMapper, SysStationRoleModel> implements ISysStationRoleService {

    /**
     * wrapper 组装器，构造条件查询
     * @author itkjb.com
     * @date  2020-08-11
     * @param wrapper
     * @param model 条件
     **/
    @Override
    protected void assembleWrapper(QueryWrapper<SysStationRoleModel> wrapper, SysStationRoleModel model) {
        // （代码生成器生成）自动生成了，list查询的时候，条件组装，开发者自行删除不需要的条件
        // 岗位id
        wrapper.lambda().eq(StringUtils.isNotBlank(model.getStationId()), SysStationRoleModel::getStationId, model.getStationId() );
        // 角色id
        wrapper.lambda().eq(StringUtils.isNotBlank(model.getRoleId()), SysStationRoleModel::getRoleId, model.getRoleId() );
    }

    /**
     * wrapper 组装器，组装list查询时，查询的列
     * @author itkjb.com
     * @date  2020-08-11
     * @param wrapper
     * @param model
     * @return void
     * @since 2020-08-11
     **/
    @Override
    protected void buildListSelectColumns(QueryWrapper<SysStationRoleModel> wrapper, SysStationRoleModel model){
        buildCommonSelectColumns(wrapper, model);
    }

    /**
     * 组装列表查询的列（字段）
     * @date  2020-08-11
     * @param wrapper
     * @param model
     */
    protected void buildCommonSelectColumns(QueryWrapper<SysStationRoleModel> wrapper, SysStationRoleModel model){
        // 代码生成器生成，为了简化开发时，查询list时，查询指定字段，没必要查询所有参数
        wrapper.lambda().select(
            // id
            SysStationRoleModel::getId,
            // 岗位id
            SysStationRoleModel::getStationId,
            // 角色id
            SysStationRoleModel::getRoleId,
            SysStationRoleModel::getCreateTime
        );
    }


}
